import numpy as np
import torch
from torch import nn, optim
import os
from dnn import DNN


# import cv2


def load_data():
    pass


path = '/home/xiaoguojian/fg2021/data'

new_path = '/home/xiaoguojian/fg2021/small_data'
folders = os.listdir(path)


def enhance(video, num=2):
    res = [[] for i in range(num)]
    flag = 100 - 100 % num
    for i, image in enumerate(video):
        if i == flag:
            break
        # cv2.resize(image, (424, 240))
        res[i % num].append(image)
    return res


for folder in folders:
    folders_path = path + '/' + folder
    files = os.listdir(folders_path)
    new_folders_path = new_path + '/' + folder
    i = 1
    for file in files:
        name = folders_path + '/' + file
        data = np.load(name)
        res = np.array(enhance(data, 2))
        for r in res:
            np.save(new_folders_path + '/' + str(i), res)
            i += 1
        print(res.shape)

# data = np.load("rgbd_stream.npy")
# result = np.array(enhance(data))
#
# print(result.shape)
